local sk__duzun = fk.CreateSkill {

  name = "sk__duzun",

  tags = { Skill.Compulsory, },

}



sk__duzun:addEffect(fk.TurnStart, {
  name = "sk__duzun",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__duzun.name) and target ~= player and not target.dead and player:getMark("sk__duzun_"..target.id) < 2
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    room:addPlayerMark(player, "sk__duzun_"..target.id, 1)
    local choices, all_choices = {"sk__duzun3"}, {"sk__duzun1", "sk__duzun2", "sk__duzun3"}
    local card = Fk:cloneCard("slash")
    local n = card.skill:getMaxUseTime(target, Player.HistoryPhase, card, nil) or 0
    if n > 0 then
      table.insert(choices, "sk__duzun1")
    end
    if player:getMark(MarkEnum.SkDrawNCards) + 2 > 0 then
      table.insert(choices, "sk__duzun2")
    end
    table.insert(choices, "sk__duzun3")
    local choice = room:askForChoice(target, choices, sk__duzun.name, "#sk__duzun-choice:"..player.id, false, all_choices)
    if choice == "sk__duzun1" then
      room:setPlayerMark(target, MarkEnum.SlashResidue, target:getMark(MarkEnum.SlashResidue) - 1)
      room:addPlayerMark(player, MarkEnum.SlashResidue, 1)
    elseif choice == "sk__duzun2" then
      room:setPlayerMark(target, MarkEnum.SkDrawNCards, target:getMark(MarkEnum.SkDrawNCards) - 1)
      room:addPlayerMark(player, MarkEnum.SkDrawNCards, 1)
    else
      room:changeMaxHp(target, -1)
      if not player.dead then
        room:changeMaxHp(player, 1)
      end
    end
  end,
})

return sk__duzun